package com.java1234.jxc.beans;

import org.nutz.dao.DB;
import org.nutz.dao.entity.annotation.*;

import java.io.Serializable;
import java.util.List;

/**
 * Created by Administrator on 2018/3/16.
 */
@Table("t_menu")
public class SysMenu implements Serializable{

    @Column
    @Comment("编号")
    @Id
    @Prev({
            @SQL(db= DB.MYSQL,value = "SELECT IFNULL(MAX(id),0)+1 FROM t_menu"),
            @SQL(db= DB.ORACLE,value = "SELECT COALESCE(MAX(id),0)+1 FROM t_menu")
    })    private Integer id;

    @Column
    @Comment("菜单名称")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String name;

    @Column
    @Comment("菜单地址")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String url;


    @Column
    @Comment("菜单节点类型 1: 根节点  0: 叶子节点")
    private Integer state;

    @Column
    @Comment("图标")
    @ColDefine(type = ColType.VARCHAR, width = 200)
    private String icon;

    @Column("p_id")
    @Comment("父级菜单ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private Integer pid;

    @ManyMany(from = "menu_id", relation = "t_role_menu", to = "role_id")
    private List<SysRole> roles;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public Integer getPid() {
        return pid;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    @Override
    public String toString() {
        return "SysMenu{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", url='" + url + '\'' +
                ", state=" + state +
                ", icon='" + icon + '\'' +
                ", pid=" + pid +
                ", roles=" + roles +
                '}';
    }
}
